package com.qsw.paper.controller.admin;

import com.qsw.paper.constant.MessageConstants;
import com.qsw.paper.pojo.vo.CollegeStudentAndAdvisorCountVO;
import com.qsw.paper.pojo.vo.CollegeThesisPassRateVO;
import com.qsw.paper.pojo.vo.StudentCountByYearVO;
import com.qsw.paper.result.Result;
import com.qsw.paper.service.ICollegesService;
import com.qsw.paper.service.IStudentsService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 数据分析 控制层
 */
@RestController
@Slf4j
@RequestMapping("/admin/data")
@RequiredArgsConstructor
public class DataController {

    private final ICollegesService collegesService;
    private final IStudentsService studentsService;


    /**
     * 前7个学院下的论文通过率（近三个月）
     *
     * @return 数据列表
     */
    @GetMapping("/collegeThesisPassRate")
    public Result<List<CollegeThesisPassRateVO>> getCollegeThesisPassRate() {
        log.info("管理员获取前7个学院下的论文通过率（近三个月）");
        List<CollegeThesisPassRateVO> result = collegesService.getCollegeThesisPassRate();
        return Result.success(result, MessageConstants.SELECT_OK);
    }

    /**
     * 获取前7个学院下的所有学生人数以及导师数量
     *
     * @return 数据列表
     */
    @GetMapping("/collegeStudentAndAdvisorCount")
    public Result<List<CollegeStudentAndAdvisorCountVO>> getCollegeStudentAndAdvisorCount() {
        log.info("管理员获取前7个学院下的所有学生人数以及导师数量");
        List<CollegeStudentAndAdvisorCountVO> result = collegesService.getCollegeStudentAndAdvisorCount();
        return Result.success(result, MessageConstants.SELECT_OK);
    }


    /**
     * 按年份展示每个学年学校的所有学生人数（近五年）
     *
     * @return 数据列表
     */
    @GetMapping("/studentCountByYear")
    public Result<List<StudentCountByYearVO>> getStudentCountByYear() {
        log.info("管理员获取学年学校的所有学生人数");
        List<StudentCountByYearVO> result = studentsService.getStudentCountByYear();
        return Result.success(result, MessageConstants.SELECT_OK);
    }

}
